package org.boticelli.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name = "twitter")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)

@NamedQueries(value = { 
    @NamedQuery(name = "TwitterEntry.findByNick", query = "select te from TwitterEntry te where te.nick = :nick")
})
public class TwitterEntry
        implements Serializable
{

    private static final long serialVersionUID = -9110032150662480221L;

    private Long id;

    private String lastTweetId;
    
    private String token;
    
    private String secret;

    private String nick;
    
    private TwitterAuth twitterAuth = TwitterAuth.NONE;

    
    public TwitterEntry()
    {
        
    }
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId()
    {
        return id;
    }
    
    public void setId(Long id)
    {
        this.id = id;
    }
    
    @Column
    public String getLastTweetId()
    {
        return lastTweetId;
    }
    
    public void setLastTweetId(String lastTweetId)
    {
        this.lastTweetId = lastTweetId;
    }

    @Column
    public String getToken()
    {
        return token;
    }

    public void setToken(String token)
    {
        this.token = token;
    }

    @Column
    public String getSecret()
    {
        return secret;
    }

    public void setSecret(String secret)
    {
        this.secret = secret;
    }

    @Column
    public String getNick()
    {
        return nick;
    }
    
    public void setNick(String nick)
    {
        this.nick = nick;
    }
    
    @Column
    public TwitterAuth getTwitterAuth()
    {
        return twitterAuth;
    }
    
    public void setTwitterAuth(TwitterAuth twitterAuth)
    {
        this.twitterAuth = twitterAuth;
    }

    @Override
    public String toString()
    {
        return super.toString() +  ": id = " + id + ", lastTweetId = " + lastTweetId + ", nick = " +
            nick + ", secret = " + secret + ", token = " + token + ", twitterAuth = " + twitterAuth;
    }
    
    
}
